package com.example.yoho.mvp.view.activity;


import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.yoho.R;

public class UserdetailsActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageView editorReturn;
    private RelativeLayout relativeIcon;
    private RelativeLayout relativeNickname;
    private TextView personName;
    private RelativeLayout relativeVip;
    private RelativeLayout relativeErweima;
    private RelativeLayout relativeCodeLing;
    private RelativeLayout relativeSex;
    private RelativeLayout relativeBirthday;
    private RelativeLayout relativeCm;
    private RelativeLayout relativeKg;
    private Button bt_canle;
    private PopupWindow popupWindow;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_userdetails);
        initView();
    }

    private void initView() {
        editorReturn = (ImageView) findViewById(R.id.editor_return);
        relativeIcon = (RelativeLayout) findViewById(R.id.relative_icon);
        relativeNickname = (RelativeLayout) findViewById(R.id.relative_nickname);
        personName = (TextView) findViewById(R.id.person_name);
        relativeVip = (RelativeLayout) findViewById(R.id.relative_vip);
        relativeErweima = (RelativeLayout) findViewById(R.id.relative_erweima);
        relativeCodeLing = (RelativeLayout) findViewById(R.id.relative_code_ling);
        relativeSex = (RelativeLayout) findViewById(R.id.relative_sex);
        relativeBirthday = (RelativeLayout) findViewById(R.id.relative_birthday);
        relativeCm = (RelativeLayout) findViewById(R.id.relative_cm);
        relativeKg = (RelativeLayout) findViewById(R.id.relative_kg);

        editorReturn.setOnClickListener(this);
        relativeNickname.setOnClickListener(this);
        personName.setOnClickListener(this);
        relativeIcon.setOnClickListener(this);
        relativeVip.setOnClickListener(this);
        relativeErweima.setOnClickListener(this);
        relativeCodeLing.setOnClickListener(this);
        relativeSex.setOnClickListener(this);
        relativeBirthday.setOnClickListener(this);
        relativeCm.setOnClickListener(this);
        relativeKg.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.editor_return:
                finish();
                break;
            case R.id.relative_icon:
                View inflate = LayoutInflater.from(this).inflate(R.layout.poupuwindow_icon, null);
                bt_canle=inflate.findViewById(R.id.bt_canle);
                bt_canle.setOnClickListener(this);
                popupWindow = new PopupWindow();
                popupWindow.setContentView(inflate);
                popupWindow.setOutsideTouchable(true);
                popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
                popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
                ColorDrawable dw = new ColorDrawable(0xb0000000);
                popupWindow.setBackgroundDrawable(dw);
                popupWindow.showAtLocation(inflate, Gravity.BOTTOM,0,0);
                break;
            case R.id.relative_nickname:
                break;
            case R.id.relative_vip:
                break;
            case R.id.relative_erweima:
                break;
            case R.id.relative_code_ling:
                break;
            case R.id.relative_sex:
                break;
            case R.id.relative_birthday:
                break;
            case R.id.relative_cm:
                break;
            case R.id.relative_kg:
                break;
            case R.id.bt_canle:
                popupWindow.dismiss();
                Toast.makeText(this, "你点击了取消", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
